package com.mali.log.consumer;

import com.mali.log.domain.po.BizLog;
import com.mali.log.service.BizLogService;
import com.mali.mq.constant.MqConstants;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
@Slf4j
@RequiredArgsConstructor
public class LogConsumer {

    private final BizLogService bizLogService;

    @RabbitListener(queues = MqConstants.LOG_QUEUE)
    public void consume(BizLog logMsg) {
        log.info("[日志服务]-[消费MQ]-接收到日志：{}", logMsg);
        bizLogService.saveLog(logMsg);
    }
}